<template>
  <view>
    <fu-custom bgColor="bg-white" :isBack="true" :isBottom="true">
      <block slot="content">{{$t('详情')}}</block>
    </fu-custom>
    <ZAudio style="height:94vh;" theme="theme1"></ZAudio>
  </view>
</template>
<script>
  import Vue from 'vue';
  import ZAudio from '@/components/uniapp-zaudio/zaudio.vue'; //HbuilderX插件导入方式, import可能需要修改目录名哦
  import ZAudio1 from '@/components/uniapp-zaudio'; //HbuilderX插件导入方式, import可能需要修改目录名哦
  export default {
    components: {
      ZAudio: ZAudio
    },
    data() {
      return {
        dataList: [],
        aid: ''
      }
    },
    onLoad(options) {
      this.aid = options.id
      this.getList()
      //挂载vue原型链上
      // var data= [{
      //     src: "https://96.f.1ting.com/local_to_cube_202004121813/96kmp3/zzzzzmp3/2016aJan/18X/18d_DeH/01.mp3",
      //     title: "恭喜发财",
      //     singer: "刘德华",
      //     coverImgUrl: "https://img.1ting.com/images/special/75/s150_f84ef5082b0420f74cd2546b986ab0fc.jpg",
      //   },
      //   {
      //     src: "https://96.f.1ting.com/local_to_cube_202004121813/96kmp3/zzzzzmp3/2015kNov/25X/25m_XiaoQ/03.mp3",
      //     title: "好运来",
      //     singer: "作者1111",
      //     coverImgUrl: "https://img.1ting.com/images/special/204/s150_77254cd4a4da1a33b8faf89c4cbf6e40.jpg",
      //   },
      // ];

    },
    methods: {
      getList() {
        let zaudio = new ZAudio1({
          continuePlay: true, //续播
          autoPlay: true, //自动播放 部分浏览器不支持
        });
        Vue.prototype.$zaudio = zaudio;
        this.$api.post(global.apiUrls.post659b87ff6c3eb, {
          aid: this.aid
        }).then(res => {
          if (res.data.code == 1) {
            this.dataList = res.data.data.map(item => {
              const obj = {
                src: item.path,
                title: item.title,
                singer: '',
                coverImgUrl: item.img
              }
              return obj;
            })
            zaudio.setAudio(this.dataList); //添加音频
            zaudio.setRender(0) //渲染第一首音频
            console.log('dataListdataListdataList', this.dataList)

          }
        })
      },
    }
  }
</script>